#pragma once
#include"Log.hpp"
#include<iostream>
#include<functional>
#include<pthread.h>

typedef function<void(int , const std::string , uint16_t )> callback_t;
using callback_t = function<void(int , const std::string , uint16_t )> ;
class Task
{
public:
    Task():sock_(-1),port_(-1)
    {}
    Task(int sock,uint16_t port,std::string ip,callback_t func)
        :sock_(sock),port_(port),ip_(ip),func_(func)
    {}
    void operator()()
    {
        logMessage(DEBUG, "线程ID[%p]处理%s:%d的请求 开始啦...",pthread_self(),ip_.c_str(),port_);
        func_(sock_,ip_,port_);
        logMessage(DEBUG, "线程ID[%p]处理%s:%d的请求 结束啦...",pthread_self(),ip_.c_str(),port_);
    }
private:
    int sock_;
    uint16_t port_;
    std::string ip_;
    callback_t func_;
};